<?php

/**
 * ResourcesAttributesData form.
 *
 * @package    rms
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ResourcesAttributesDataForm extends BaseResourcesAttributesDataForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'resource'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Resources'), 'add_empty' => false)),
      'weight'      => new sfWidgetFormInputText( array('default' => '0')),
      'name'        => new sfWidgetFormInputText(),
      'description' => new sfWidgetFormTextarea(),
//       'value'       => new sfWidgetFormInputText(),
      'type'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('DataTypes'), 'add_empty' => false)),
      
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'resource'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Resources'))),
      'weight'      => new sfValidatorPass(),
      'name'        => new sfValidatorPass(),
      'description' => new sfValidatorPass(array('required' => false)),
//       'value'       => new sfValidatorPass(),
      'type'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('DataTypes'))),
      ));

    $this->widgetSchema->setLabels(array(
      'resource'  => 'Recurso',
      'weight' => 'Peso',
      'name' => 'Nombre',
      'description' => 'Descripción',
//       'value' => 'Valor',
      'type' => 'Tipo',
    ));

    $this->widgetSchema['type']->setAttribute('onclick','changeType( this.value )');
  }

  public function add($num)
  {
/*    $pic = new Picture();
    $pic->setCard($this->getObject());
    $pic_form = new PictureForm($pic);

    //Empotramos la nueva pícture en el contenedor
    $this->embeddedForms['pictures']->embedForm($num, $pic_form);
    //Volvemos a empotrar el contenedor
    $this->embedForm('pictures', $this->embeddedForms['pictures']);  */     
  }

  public function type( $t )
  {
/*    $pic = new Picture();
    $pic->setCard($this->getObject());
    $pic_form = new PictureForm($pic);

    //Empotramos la nueva pícture en el contenedor
    $this->embeddedForms['pictures']->embedForm($num, $pic_form);
    //Volvemos a empotrar el contenedor
    $this->embedForm('pictures', $this->embeddedForms['pictures']);    */   
  }
}
